var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp(), e = !0;

Page({
    data: {
        active: null,
        years: "",
        title: "极差奖励",
        showPicker: !1,
        list: [],
        info: [],
        nowYears: new Date().getFullYear(),
        getUrl: "",
        getDetailUrl: "",
        tapind: ""
    },
    onLoad: function(t) {
        var a, e, s = "";
        0 == t.ind ? (s = "极差奖励", a = "plugin.agency-subsidy.frontend.controllers.records.order.index", 
        e = "plugin.agency-subsidy.frontend.controllers.records.order.detail") : 1 == t.ind ? (s = "层级奖励", 
        a = "plugin.agency-subsidy.frontend.controllers.records.level.index", e = "plugin.agency-subsidy.frontend.controllers.records.level.detail") : 2 == t.ind ? (s = "补贴奖励", 
        a = "plugin.agency-subsidy.frontend.controllers.records.subsidy.index", e = "plugin.agency-subsidy.frontend.controllers.records.subsidy.detail") : 3 == t.ind && (s = "业绩奖励", 
        a = "plugin.agency-subsidy.frontend.controllers.records.performance.index", e = "plugin.agency-subsidy.frontend.controllers.records.performance.detail"), 
        wx.setNavigationBarTitle({
            title: s
        }), this.setData({
            active: t.ind,
            getUrl: a,
            getDetailUrl: e,
            tapind: t.ind
        }), this.getData();
    },
    onReady: function() {},
    pickChange: function(t) {
        var a = t.detail.value;
        this.setData({
            nowYears: a,
            list: []
        }), this.getData();
    },
    tabChange: function(t) {
        var a = t.detail.index;
        console.log(a), this.setData({
            active: a,
            nowYears: new Date().getFullYear(),
            list: []
        }), this.getData();
    },
    moreShowTap: function(a) {
        console.log(a);
        var e = a.currentTarget.dataset.item, s = a.currentTarget.dataset.ind, n = a.currentTarget.dataset.index;
        e.info[s].moreShow || this.setData(t({}, "list[" + n + "].info[" + s + "].moreShow", !0));
    },
    showGoods: function(a) {
        var e = a.currentTarget.dataset.ind, s = a.currentTarget.dataset.index, n = a.currentTarget.dataset.itemk;
        this.setData(t({}, "list[" + s + "].info[" + e + "].show", !n.show));
    },
    tapGetList: function(a) {
        var e, s = a.currentTarget.dataset.item, n = a.currentTarget.dataset.index;
        s.show ? this.setData(t({}, "list[" + n + "].show", !s.show)) : (this.setData((t(e = {}, "list[" + n + "].show", !s.show), 
        t(e, "list[" + n + "].page", 1), t(e, "list[" + n + "].last_page", 1), e)), this.getDetail(s, n));
    },
    getDetail: function(e, s) {
        var n = this, i = a.getNetAddresss(this.data.getDetailUrl), r = {
            year: e.year,
            month: e.month,
            award_status: 2 == this.data.active ? "-1" : this.data.active,
            page: e.page
        };
        a._getNetWork({
            url: i,
            data: r,
            success: function(e) {
                var i, r = e.data;
                if (1 != r.result) return a.tips(r.msg);
                if (0 == n.data.tapind || 1 == n.data.tapind) for (var o = 0; o < r.data.data.length; o++) r.data.data[o].order_goods.length > 0 && (r.data.data[o].show = !1);
                n.setData((t(i = {}, "list[" + s + "].info", r.data.data), t(i, "list[" + s + "].last_page", r.data.last_page), 
                i)), console.log(n.data.list);
            }
        });
    },
    getMore: function(s) {
        var n = this, i = s.currentTarget.dataset.item, r = s.currentTarget.dataset.index, o = {
            year: i.year,
            month: i.month,
            award_status: 2 == this.data.active ? "-1" : this.data.active,
            page: i.page + 1
        }, d = a.getNetAddresss(this.data.getDetailUrl);
        i.page >= i.last_page || (e ? (e = !1, a._getNetWork({
            url: d,
            data: o,
            success: function(s) {
                var i;
                e = !0, 0 == s.result && a.tips(o.msg);
                var o = s.data, d = o.data.data;
                n.data.list[r].info = n.data.list[r].info.concat(d), n.setData((t(i = {}, "list[" + r + "].info", n.data.list[r].info), 
                t(i, "list[" + r + "].last_page", o.data.last_page), t(i, "list[" + r + "].page", o.data.current_page), 
                i));
            },
            fail: function(t) {
                e = !0;
            }
        })) : console.log("请求中"));
    },
    getData: function() {
        var t = this, e = "";
        e = 2 == this.data.active ? "-1" : this.data.active;
        var s = {
            year: this.data.nowYears,
            award_status: e
        }, n = a.getNetAddresss(this.data.getUrl);
        a._getNetWork({
            url: n,
            data: s,
            success: function(e) {
                var s = e.data;
                if (1 != s.result) return a.tips(s.msg);
                for (var n = 0; n < s.data.length; n++) s.data[n].amounts > 0 && (s.data[n].show = !1);
                t.setData({
                    list: s.data
                });
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});